package com.xuqm.sdhbwfu.app.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.xuqm.base.di.manager.HttpManager
import com.xuqm.base.extensions.showMessage
import com.xuqm.sdhbwfu.app.model.SchedulingModel
import com.xuqm.sdhbwfu.app.repository.Service
import com.xuqm.sdhbwfu.core.extensions.io_main
import com.xuqm.sdhbwfu.core.extensions.subscribeBy
import com.xuqm.sdhbwfu.core.viewModel.BaseViewModel

class SchedulingViewModel : BaseViewModel() {

    private val _list = MutableLiveData<List<SchedulingModel>>()
    val list: LiveData<List<SchedulingModel>> = _list

    fun inspectionList() {
        HttpManager.getApi(Service::class.java)
            .schedulingList()
            .io_main()
            .subscribeBy(
                {
                    _list.postValue(it)
                }, {
                    _list.postValue(null)
                    showMessage(it)
                }
            ).adds()
    }
}